Skip to content

feat: define clamp_limit behavior contract for pagination#402

Merged
Baskarayelu merged 2 commits intoRemitwise-Org:mainfrom
emperorsixpacks:feature/common-clamp-limit-contract
Mar 28, 2026
Merged

feat: define clamp_limit behavior contract for pagination#402
Baskarayelu merged 2 commits intoRemitwise-Org:mainfrom
emperorsixpacks:feature/common-clamp-limit-contract

Conversation

@emperorsixpacks
Copy link
Copy Markdown
Contributor

Fixes #327

Summary

Defines an explicit behavior contract for clamp_limit in remitwise-common/src/lib.rs to ensure consistent pagination across all contracts.

Changes

  • Added full NatSpec-style doc comment with behavior table, invariants, security assumptions, and usage examples
  • Fixed duplicate INSTANCE_BUMP_AMOUNT / INSTANCE_LIFETIME_THRESHOLD constant definitions (removed conflicting redeclarations at bottom of file)
  • Added DAY_IN_LEDGERS, PERSISTENT_BUMP_AMOUNT, PERSISTENT_LIFETIME_THRESHOLD constants
  • Added 11 comprehensive unit tests + 1 doc-test covering all contract invariants

Test Results

running 11 tests ... all ok
doc-tests: 1 passed

Invariants Verified

  • clamp_limit(0) == DEFAULT_PAGE_LIMIT
  • clamp_limit(MAX_PAGE_LIMIT) == MAX_PAGE_LIMIT
  • clamp_limit(MAX_PAGE_LIMIT + 1) == MAX_PAGE_LIMIT
  • Return always in [1, MAX_PAGE_LIMIT], never zero
  • Function is idempotent

@Baskarayelu Baskarayelu merged commit ff910ba into Remitwise-Org:main Mar 28, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement clamp_limit behavior contract for pagination helpers

2 participants